/*
* @Author: Adolphus.Yao
* @Date:   2019-10-16 14:17:25
* @Last Modified by:   Adolphus.Yao
* @Last Modified time: 2019-10-16 14:17:25
*/
package main

import (
    "html/template"
    "os"
)

type EntetiesClass struct {
    Name  string
    Value int32
}

// In the template, we use rangeStruct to turn our struct values
// into a slice we can iterate over
const htmlTemplate = `
{{range $index, $element := .}}
    {{$index}}
        {{range $element}}
            {{.Name}} {{.Value}}
        {{end}}
{{end}}
`

func main() {
    data := map[string][]EntetiesClass{
        "Yoga":    {{"Yoga1", 13}, {"Yoga2", 15}},
        "Pilates": {{"Pilates1", 3}, {"Pilates2", 6}, {"Pilates3", 9}},
    }

    t, _ := template.ParseFiles("html/t.html")

    err = t.Execute(os.Stdout, data)
    if err != nil {
        panic(err)
    }
}
